package com.wgo.bpot.domain.common;

import com.wgo.bpot.domain.common.impl.UserImpl;

public class UserCredential {
	private String userName;
	private long passwordHashCode;
		
	public UserCredential(String userName, String password) {
		this.userName = null == userName ? "" : userName;
		setPassword(null == password ? "" : password);
	}
	
	public long getPasswordHashCode() {
		return passwordHashCode;
	}
	public void setPassword(String password) {
		if (null == password){
			throw new NullPointerException("Password cannot be 'null'");
		}
		this.passwordHashCode = UserImpl.createHashCode(password);
	}
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		if (null == userName){
			throw new NullPointerException("Username cannot be 'null'");
		}
		this.userName = userName;
	}

    @Override
    public String toString() {
        return userName + " / " + passwordHashCode;
    }
    
    
}
